<?php

namespace App\Admin\Extensions;

use App\Model\HostApplyLog;
use Encore\Admin\Admin;

class HostOp extends BaseAction
{
    protected function render()
    {
        Admin::script($this->script($this->actionUrl));
        $detailbtn = $this->buildButton('link', '详情', ['id' => $this->id, 'url' => "host_apply/{$this->id}/edit"]);
        $okbtn = $this->buildButton('ok', '审核通过', ['id' => $this->id, 'status' => HostApplyLog::STATUS_OK]);
        $failbtn = $this->buildButton('fail', '取消女用户', ['id' => $this->id, 'status' => HostApplyLog::STATUS_FAIL]);
        $str = '';
        if ($this->row->status == HostApplyLog::STATUS_ING) {
            $str  = [$detailbtn, $okbtn];
        } elseif ($this->row->status == HostApplyLog::STATUS_OK) {
            $str  = [$detailbtn, $failbtn];
        } elseif ($this->row->status == HostApplyLog::STATUS_FAIL) {
            $str  = [$detailbtn, $okbtn];
        }
        return implode('<br/><br/>', $str);
    }
}
